<!--学生考勤-->
<template>
  <div class="log">
    <basic-container>
      <avue-crud
          ref="crud"
          :data="tableData"
          :option="tableOption"
          :page.sync="page"
          :permission="permissionList"
          :table-loading="tableLoading"
          @search-reset="searchReset"
          @on-load="getList"
          @search-change="searchChange"
          @refresh-change="refreshChange"
          @size-change="sizeChange"
          @current-change="currentChange">
        <template slot="direction" slot-scope="scope">
          <el-tag v-if="scope.row.direction === 1">{{ scope.label }}</el-tag>
          <el-tag v-else-if="scope.row.direction === 0">{{ scope.label }}</el-tag>
          <el-tag v-else type="info">无</el-tag>
        </template>
        <template slot="created" slot-scope="scope">
          <el-tag v-if="scope.row.created === null" type="info">无</el-tag>
          <el-tag v-else>{{ scope.row.created }}</el-tag>
        </template>
        <template slot="groupName" slot-scope="scope">
          <p v-if="scope.row.groupName === null">无</p>
          <p v-else>{{ scope.row.groupName }}</p>
        </template>
        <template slot="checkinState" slot-scope="scope">
          <el-tag v-if="scope.row.paramCheckinState === 1" effect="dark" size="medium" type="success">正常</el-tag>
          <el-tag v-else-if="scope.row.paramCheckinState === 2" effect="dark" size="medium" type="warning">迟到</el-tag>
          <el-tag v-else-if="scope.row.paramCheckinState === 0" effect="dark" size="medium" type="danger">缺勤</el-tag>
          <el-tag v-else-if="scope.row.paramCheckinState === 3" effect="dark" size="medium" type="info">非考勤时段</el-tag>
          <el-tag v-else size="medium" type="info">无</el-tag>
        </template>
        <template slot="leave" slot-scope="scope">
          <el-button v-if="scope.row.personLeaveId !== null" effect="dark" size="mini" type="success"
                     @click="showLeave(scope.row)">请假
          </el-button>
          <el-tag v-else-if="scope.row.personLeaveId === null" size="medium" type="info">无</el-tag>
        </template>
        <template slot="menuLeft">
          <el-button
              class="filter-item"
              icon="el-icon-download"
              size="small"
              type="warning"
              @click="exportItemVisible()">数据导出
          </el-button>
        </template>
      </avue-crud>

      <el-dialog
          :visible.sync="dialogLeaveVisible"
          title="查看"
          width="40%"
          @close="dictItemVisible"
          :close-on-click-modal="false">
        <el-form :model="detailform">
          <el-form-item style="border-radius: 10px;padding: 10px 0 10px 30px;box-shadow: 0 0 5px 2px #e5e5e5;">
            <el-col :span="12">
              <p style="margin: 0">姓名：{{ detailform.name }}</p>
            </el-col>
            <el-col :span="12">
              <p v-if="detailform.sex === 0" style="margin: 0">性别：女</p>
              <p v-else style="margin: 0">性别：男</p>
            </el-col>
            <el-col :span="12">
              <p style="margin: 0">年级：{{ detailform.gradeName }}</p>
            </el-col>
            <el-col :span="12">
              <p style="margin: 0">班级：{{ detailform.className }}</p>
            </el-col>
            <el-col :span="12">
              <p style="margin: 0">属性：{{ detailform.identity }}</p>
            </el-col>
            <el-col :span="12">
              <p style="margin: 0">学号：{{ detailform.number }}</p>
            </el-col>
          </el-form-item>


          <el-form-item style="border-radius: 10px;padding: 10px 0 10px 30px;box-shadow: 0 0 5px 2px #e5e5e5;">
            <el-col :span="12">
              <p v-if="detailform.leaveStatus === 1" style="margin: 0">当前状态：已通过</p>
              <p v-else style="margin: 0">当前状态：</p>
            </el-col>
            <el-col :span="12">
              <p style="margin: 0">请假发起人：{{ detailform.createUser }}</p>
            </el-col>
            <el-col :span="12">
              <p v-if="this.eye === false" style="margin: 0">发起人电话：{{ this.newphone }}
                <i class="icon-huabanfuben" style="margin:0 0 0 10px;font-size: 14px!important;" @click="showPhone"/>
              </p>
              <p v-else style="margin: 0">发起人电话：{{ detailform.linkPhone }}
                <i class="icon-yanjing1" style="margin:0 0 0 10px;font-size: 14px!important;" @click="showPhone"/>
              </p>
            </el-col>
            <el-col :span="12">
              <p style="margin: 0">发起时间：{{ detailform.createTime }}</p>
            </el-col>
            <el-col :span="12">
              <p v-if="detailform.leaveType === 0" style="margin: 0">请假类型：事假</p>
              <p v-if="detailform.leaveType === 1" style="margin: 0">请假类型：病假</p>
              <p v-if="detailform.leaveType === 2" style="margin: 0">请假类型：晚休</p>
            </el-col>
            <el-col :span="12">
              <p style="margin: 0">请假开始时间：{{ detailform.startTime }}</p>
            </el-col>
            <el-col v-if="detailform.leaveType === 1" :span="12">
              <p style="margin: 0;display: none">请假结束时间：{{ detailform.endTime }}</p>
            </el-col>
            <el-col v-else :span="12">
              <p style="margin: 0">请假结束时间：{{ detailform.endTime }}</p>
            </el-col>
            <el-col v-if="detailform.leaveType === 1" :span="12">
              <p style="margin: 0;display: none">请假时长：{{ detailform.durationDay }}天{{ detailform.durationHour }}时</p>
            </el-col>
            <el-col v-else :span="12">
              <p style="margin: 0">请假时长：{{ detailform.durationDay }}天{{ detailform.durationHour }}时</p>
            </el-col>
            <el-col :span="12">
              <p style="margin: 0">请假理由：{{ detailform.cause }}</p>
            </el-col>
          </el-form-item>

          <el-form-item v-if="detailform.leaveType === 1"
                        style="border-radius: 10px;padding: 10px 0 10px 30px;box-shadow: 0 0 5px 2px #e5e5e5;">
            <el-col :span="24">
              <p v-if="detailform.doctorApprove === 0" style="margin: 0">校医审批结果：待审</p>
              <p v-if="detailform.doctorApprove === 1" style="margin: 0">校医审批结果：通过</p>
              <p v-if="detailform.doctorApprove === 2" style="margin: 0">校医审批结果：驳回</p>
              <p v-if="detailform.doctorApprove === 3" style="margin: 0">校医审批结果：中断</p>
            </el-col>
            <div v-if="detailform.doctorApprove === 0">
              <el-col :span="24" style="display: none">
                <p style="margin: 0">校医审批时间：{{ detailform.doctorApproveTime }}</p>
              </el-col>
              <el-col :span="24" style="display: none">
                <p style="margin: 0">校医审批反馈：{{ detailform.doctorApproveAdvice }}</p>
              </el-col>
            </div>
            <div v-else-if="detailform.doctorApprove === 3">
              <el-col :span="24" style="display: none">
                <p style="margin: 0">校医审批时间：{{ detailform.doctorApproveTime }}</p>
              </el-col>
              <el-col :span="24" style="display: none">
                <p style="margin: 0">校医审批反馈：{{ detailform.doctorApproveAdvice }}</p>
              </el-col>
            </div>
            <div v-else>
              <el-col :span="24">
                <p style="margin: 0">校医审批时间：{{ detailform.doctorApproveTime }}</p>
              </el-col>
              <el-col :span="23">
                <p style="margin: 0">校医审批反馈：{{ detailform.doctorApproveAdvice }}</p>
              </el-col>
            </div>
          </el-form-item>

          <el-form-item v-if="detailform.leaveType === '事假'">
            <el-form-item
                style="border-radius: 10px;float:left;padding: 10px 0 10px 30px;box-shadow: 0 0 5px 2px #e5e5e5;width: 48%;display: inline-block">
              <el-col :span="24">
                <p v-if="detailform.parentApprove === 0" style="margin: 0">家长审批结果：待审</p>
                <p v-if="detailform.parentApprove === 1" style="margin: 0">家长审批结果：通过</p>
                <p v-if="detailform.parentApprove === 2" style="margin: 0">家长审批结果：驳回</p>
                <p v-if="detailform.parentApprove === 3" style="margin: 0">家长审批结果：中断</p>
              </el-col>
              <el-col :span="24">
                <p style="margin: 0">家长审批时间：{{ detailform.parentApproveTime }}</p>
              </el-col>
              <el-col :span="24">
                <p style="margin: 0">家长审批反馈：{{ detailform.parentApproveAdvice }}</p>
              </el-col>
            </el-form-item>


            <el-form-item
                style="border-radius: 10px;float:right;padding: 10px 0 10px 30px;box-shadow: 0 0 5px 2px #e5e5e5;width: 48%;display: inline-block">
              <el-col :span="24">
                <p v-if="detailform.teacherApprove === 0" style="margin: 0">班主任审批结果：待审</p>
                <p v-if="detailform.teacherApprove === 1" style="margin: 0">班主任审批结果：通过</p>
                <p v-if="detailform.teacherApprove === 2" style="margin: 0">班主任审批结果：驳回</p>
                <p v-if="detailform.teacherApprove === 3" style="margin: 0">班主任审批结果：中断</p>
              </el-col>
              <el-col :span="24">
                <p style="margin: 0">班主任审批时间：{{ detailform.teacherApproveTime }}</p>
              </el-col>
              <el-col :span="24">
                <p style="margin: 0">班主任审批反馈：{{ detailform.teacherApproveAdvice }}</p>
              </el-col>
            </el-form-item>


            <el-form-item v-if="detailform.durationDay >= 3 "
                          style="border-radius: 10px;float:left;padding: 10px 0 10px 30px;box-shadow: 0 0 5px 2px #e5e5e5;width: 48%;display: inline-block">
              <el-col :span="24">
                <p v-if="detailform.prefectApprove === 0" style="margin: 0">级长审批结果：待审</p>
                <p v-if="detailform.prefectApprove === 1" style="margin: 0">级长审批结果：通过</p>
                <p v-if="detailform.prefectApprove === 2" style="margin: 0">级长审批结果：驳回</p>
                <p v-if="detailform.prefectApprove === 3" style="margin: 0">级长审批结果：中断</p>
              </el-col>
              <el-col :span="24">
                <p style="margin: 0">级长审批时间：{{ detailform.prefectApproveTime }}</p>
              </el-col>
              <el-col :span="24">
                <p style="margin: 0">级长审批反馈：{{ detailform.prefectApproveAdvice }}</p>
              </el-col>
            </el-form-item>


            <el-form-item v-if="detailform.durationDay > 7"
                          style="border-radius: 10px;float:right;padding: 10px 0 10px 30px;box-shadow: 0 0 5px 2px #e5e5e5;width: 48%;display: inline-block">
              <el-col :span="24">
                <p v-if="detailform.leadersApprove === 0" style="margin: 0">领导审批结果：待审</p>
                <p v-if="detailform.leadersApprove === 1" style="margin: 0">领导审批结果：通过</p>
                <p v-if="detailform.leadersApprove === 2" style="margin: 0">领导审批结果：驳回</p>
                <p v-if="detailform.leadersApprove === 3" style="margin: 0">领导审批结果：中断</p>
              </el-col>
              <el-col :span="24">
                <p style="margin: 0">领导审批时间：{{ detailform.leadersApproveTime }}</p>
              </el-col>
              <el-col :span="24">
                <p style="margin: 0">领导审批反馈：{{ detailform.leadersApproveAdvice }}</p>
              </el-col>
            </el-form-item>
          </el-form-item>
        </el-form>
      </el-dialog>

    </basic-container>
  </div>
</template>

<script>
import {StudentCheck, StudentLeave} from '@/api/check/student-check'
import {mapGetters} from 'vuex'
import {LEAVE_DETAILS, LEAVE_SEX} from '@/const/Leave'
import {CHECK_LEAVE, CHECK_STATE, DIRECTION} from '@/const/Dict'
import {PERSON_DETAILS} from "@/const/personDict";

export default {
  name: 'student-check',
  components: {
  },
  data() {
    return {
      dialogLeaveVisible: false,
      eye: false,
      tableData: [],
      group: [],
      searchForm: {},
      detailform: {},
      phone: '',
      newphone: '',
      page: {
        total: 0, // 总页数
        currentPage: 1, // 当前页数
        pageSize: 10 // 每页显示多少条
      },
      // params: {
      //   center: '',
      // },
      tableLoading: false,
      // tableOption: tableOption,
      tableOption: {
        border: true,  //竖线边框
        index: true,  //表格序号
        indexLabel: '序号',  //序号的标题
        stripe: true,  //是否显示表格的斑马条纹
        menuAlign: 'center',  //菜单栏对齐方式
        menuWidth: 120,  //操作菜单栏的宽度
        align: 'center',  //表格列对其方式
        emptyBtnText: '重置', //清空按钮文案
        searchMenuSpan: 6,  //搜索及清空等操作按钮一栏长度
        // searchSpan: 4,  //搜索框长度
        addBtn: false,  //添加按钮
        delBtn: false,  //行内删除按钮
        editBtn: false,  //行内编辑按钮
        viewBtn: false,  //是否显示查看按钮
        selection: false,  //表格是否显示可选
        excelBtn: false,  //表格导出按钮是否显示
        refreshBtn: true,  //表格上面小的 刷新按钮
        columnBtn: false,  //表格上面小的 列表显隐按钮
        searchBtn: true,  //搜索按钮
        // menu:true,  //是否显示操作栏
        menuType: 'button',//操作栏样式为按钮
        menu: false,
        searchLabelWidth: 85,  //搜索框前标题宽度
        labelWidth: '30%',  //行内查看弹窗的标题宽度
        props: {
          label: 'label',
          value: 'value'
        },
        column: [
          {
            label: 'kid',
            prop: 'kid',
            search: false,
            hide: true,
          },
          {
            label: '人员id',
            prop: 'userCode',
            search: false,
            hide: true,
          },
          {
            width: 162,
            label: '姓名',
            prop: 'name',
            search: true,
            dicData: LEAVE_DETAILS,  //引入字典
          }, {
            label: '性别',
            prop: 'sex',
            search: true,
            type: 'select',  //搜索框显示类型
            dicData: LEAVE_SEX,
            change: (value) => {
              // if(value.value === ''){
              //   return;
              // }
              this.searchForm.sex = value.value
              this.getList(this.page, this.searchForm)
            },
          }, {
            label: '校区',
            prop: 'campusDeptArea',
            dicData: PERSON_DETAILS,
            editDisplay: false,
          },{
            label: '年级',
            prop: 'parentName',
            search: false,
            type: 'select',
            dicData: LEAVE_DETAILS,
          },
          {
            label: '年级',
            prop: 'deptId',
            search: true,
            type: 'select',
            hide: true,
            // searchClearable: false,
            // dicUrl: '/campus/sysdept/detpTree/1/2',
            dicData: [
              {
                label: "初一",
                value: '650'
              },
              {
                label: "初二",
                value: '655'
              },
              {
                label: "初三",
                value: '97'
              },
              {
                label: "高一",
                value: '127'
              },
              {
                label: "高二",
                value: '126'
              },
              {
                label: "高三",
                value: '128'
              },
            ],
            cascaderItem: ['deptName'],
            // dicMethod: 'get',
            // props: {
            //   label: 'name',
            //   value: 'deptId'
            // },
            change: (value) => {
              this.searchForm.deptId = value.value
              this.getList(this.page, this.searchForm)
            },
          },
          {
            label: '班级',
            prop: 'deptName',
            search: true,
            filter: false,
            type: 'select',
            // hide: true,
            // searchClearable: false,
            defaultExpandAll: true,
            dicUrl: '/campus/sysdept/detpTree/{{key}}/1,2,3',
            dicFormatter: (res) => {
              // console.log(res.data[0].children)
              return res.data[0].children;//返回字典的层级结构
            },
            dicMethod: 'get',
            props: {
              label: 'name',
              value: 'deptId',
            },
            change: (value) => {
              // if(value.value === ''){
              //   return;
              // }
              this.searchForm.deptId = value.value
              this.getList(this.page, this.searchForm)
            },
          },
          // {
          //   label: '班级',
          //   prop: 'deptName',
          //   search: false,
          //   type: 'select',
          //   dicData: LEAVE_DETAILS,
          // },
          {
            label: '学生属性',
            prop: 'identityKey',
            search: true,
            type: 'select',
            dicUrl: '/campus/identity/selectAll?groupNum=2',
            dicMethod: 'get',
            props: {
              label: 'name',
              value: 'id'
            },
            change: (value) => {
              // if(value.value === ''){
              //   return;
              // }
              this.searchForm.identityKey = value.value
              this.getList(this.page, this.searchForm)
            },
          },
          {
            label: '楼栋',
            prop: 'buildingName',
            dicData: PERSON_DETAILS,
          },
          {
            label: '楼栋',
            prop: 'buildingId',
            hide: true,
            search: true,
            type: 'select',
            dicUrl: '/campus/building/selectAll',
            dicMethod: 'get',
            props: {
              label: 'buildingName',
              value: 'buildingId'
            },
            change: (value) => {
              // if(value.value === ''){
              //   return;
              // }
              this.searchForm.buildingId = value.value
              this.getList(this.page, this.searchForm)
            },
          }, {
            label: '宿舍号',
            prop: 'dormNumber',
            search: true,
            type: 'input',
            dicData: LEAVE_DETAILS,
          },
          {
            label: '考勤地点',
            prop: 'groupName',
            slot: true,
          },
          {
            label: '考勤地点',
            prop: 'accessGroupId',
            search: true,
            hide: true,
            type: 'select',
            dicUrl: '/campus/accesscontrolgroup/selectAll',
            dicMethod: 'get',
            props: {
              label: 'groupName',
              value: 'id'
            },
            change: (value) => {
              // if(value.value === ''){
              //   return;
              // }
              this.searchForm.accessGroupId = value.value
              this.getList(this.page, this.searchForm)
            },
          }, {
            label: '进出口',
            prop: 'direction',
            search: false,
            type: 'select',
            dicData: DIRECTION,
            slot: true,
          }, {
            label: '体温',
            prop: 'deviceTemp',
            search: false,
            dicData: LEAVE_DETAILS,
          },
          {
            label: '考勤时间',
            prop: 'created',
            type: 'datetime',
            width: 155,
            format: 'yyyy-MM-dd HH:mm:ss',
            valueFormat: 'yyyy-MM-dd HH:mm:ss',
            search: false,
            // dicData: LEAVE_DETAILS,
            slot: true,
          },
          {
            label: '考勤日期',
            prop: 'startTime',
            type: 'date',
            format: 'yyyy-MM-dd',
            valueFormat: 'yyyy-MM-dd',
            search: true,
            searchClearable: false,
            hide: true,
            searchRules: [
              {
                required: true,
                trigger: "none",
                message: '请输入考勤日期'
              }
            ]
          },
          {
            label: '考勤时间',
            prop: 'endTime',
            search: true,
            searchClearable: false,
            type: 'select',
            hide: true,
            clearable: false,
            dicData: [
              {
                label: '06:00-07:35',
                value: '06:00-07:35-11:59',
              },
              {
                label: '12:00-13:20',
                value: '12:00-13:20-13:49'
              },
              {
                label: '13:50-14:25',
                value: '13:50-14:25-16:39-12:00-13:20'
              },
              {
                label: '16:00-19:30',
                value: '16:00-19:30-20:29'
              },
              {
                label: '20:30-21:00',
                value: '20:30-21:00-22:09'
              },
              {
                label: '22:10-22:40',
                value: '22:10-22:40-22:40'
              },
            ],
            searchRules: [
              {
                required: true,
                trigger: "none",
                message: '请输入考勤时间'
              }
            ]
          },
          {
            label: '请假',
            prop: 'leave',
            slot: true,
            search: true,
            type: 'select',
            dicData: CHECK_LEAVE,
            change: (value) => {
              // if(value.value === ''){
              //   return;
              // }
              this.searchForm.leave = value.value
              this.getList(this.page, this.searchForm)
            },
            // clear:() =>{
            //   debugger
            //   // this.searchForm.leave = value.value
            //   this.getList(this.page,)
            // }
          },
          {
            label: '考勤状态',
            prop: 'checkinState',
            search: true,
            dicData: CHECK_STATE,
            slot: true,
            type: 'select',
          },
        ]
      }
    }
  },
  computed: {
    ...mapGetters(['permissions']),
    permissionList() {
      return {
        delBtn: this.vaildData(this.permissions.sys_log_del, true)
      }
    },
  },
  created() {
    //获取跳转入参
    let param = this.$route.query;
    // 默认当前日期展示
    let columndate = this.findObject(this.tableOption.column, "startTime");
    this.Date = new Date();
    // 获取当前年
    this.year = this.Date.getFullYear();
    // 获取当前月
    this.month = this.Date.getMonth() + 1;
    // 获取当前日
    this.date = this.Date.getDate();
    //  自动补0
    this.month = (this.month < 10) ? '0' + this.month : this.month = this.month;
    this.date = (this.date < 10) ? '0' + this.date : this.date = this.date;

    if (param.date === undefined) {
      columndate.searchValue = this.year + '-' + this.month + '-' + this.date;
    } else {
      columndate.searchValue = param.date
    }
    console.log(columndate.searchValue)

    // 默认时间段展示
    let columntime = this.findObject(this.tableOption.column, "endTime");

    if (param.timeslot === undefined) {
      columntime.searchValue = '06:00-07:35-11:59'
    } else {
      columntime.searchValue = param.timeslot
    }

    //年级的反参处理
    let columngrade = this.findObject(this.tableOption.column, "deptId");
    // let gradearr = []
    // gradeObj().then(res => {
    //   gradearr = res.data.data[0].children
    //   // console.log(gradearr)
    //   columngrade.dicData = []
    //   columngrade.dicData = gradearr
    //   // console.log(columngrade)
    // })
    if (param.deptId !== undefined) {
      columngrade.searchValue = param.deptId
    }
    //  考勤状态的带参
    let columnstate = this.findObject(this.tableOption.column, "checkinState");

    if (param.checkinState !== undefined) {
      columnstate.searchValue = param.checkinState
    }
    //  请假状态的带参
    let columnleave = this.findObject(this.tableOption.column, "leave");

    if (param.leave !== undefined) {
      columnleave.searchValue = param.leave
    }
  },
  methods: {
    getList(page, params) {
      this.tableLoading = true
      let param = this.$route.query;
      console.log(param)
      // debugger
      if (param.flag === '1') {
        this.time = param.timeslot.split('-')
        param.startTime = param.date + " " + this.time[0] + ':00'
        param.endTime = param.date + " " + this.time[2] + ':00'
        // this.searchForm.deptId = param.deptId
        // this.searchForm.checkinState = param.checkinState
        // param.filterStartTime = param.date + " " + this.time[0] + ':00'
        // param.filterEndTime = param.date + " " + this.time[1] + ':00'
        param.paramCheckinTime = param.date + " " + this.time[1] + ':00'
        // this.searchForm.leave = param.leave
        StudentCheck(Object.assign({
          // descs: 'create_time',
          // paramCheckinTime: param.center,
          current: page.currentPage,
          size: page.pageSize
        }, params, param)).then(response => {
          this.tableData = response.data.data.records
          this.page.total = response.data.data.total
          this.tableLoading = false
          param.flag = null
        })
      } else {
        StudentCheck(Object.assign({
          // descs: 'create_time',
          paramCheckinTime: this.searchForm.center,
          current: page.currentPage,
          size: page.pageSize
        }, param, this.searchForm)).then(response => {
          console.log(params)
          this.tableData = response.data.data.records
          this.page.total = response.data.data.total
          this.tableLoading = false
        })
      }
    },

    //导出文件
    exportItemVisible() {
      const h = this.$createElement
      this.$confirm('确定要导出当前筛选条件下的人员吗?', '导出excel', {
        message: h('p', null, [
          h('h3', {style: 'font-weight:bold;'}, '确定要导出当前筛选条件下的人员吗?'),
          h('p', {style: 'color:red'}, '导出文件需要较长时间，请耐心等待'),
        ]),
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        closeOnClickModal:false,
      }).then(() => {
        let loading = this.$loading({
          lock: true,
          text: '导出中，请稍等'
        })
        axios({
          method: 'get',
          url: 'campus/access_records/excel_export',
          params: this.searchForm,
          timeout: 600000,
          headers: {
            key: ''
          },
          responseType: "blob"
        }).then(res => {
          if (res.data.type) {
            // 文件下载
            const blob = new Blob([res.data], {
              type: "application/vnd.ms-excel"
            });
            let link = document.createElement('a');
            link.href = URL.createObjectURL(blob);
            link.setAttribute('download', '学生考勤导出文件.xlsx');
            link.click();
            link = null;
            loading.close()
            this.$message.success('导出成功');
          } else {
            // 返回json
            this.$message.warning(res.data.msg);
          }
        })
            .catch(err => {
              loading.close()
              this.$message.error("下载失败");
            });
      })
    },

    showPhone() {
      let that = this;
      if (that.eye) {
        that.eye = false
      } else {
        that.eye = true
      }
    },
    searchChange(form, done) {
      // debugger
      //  截取写死的时间段  start和end 为组合后的入参 再赋值给入参的startTime和endTime
      //  考勤状态选择要另外传入 实际时间段的结束时间和开始时间
      // 4/20  班级的手动搜索 deptName赋值给deptId
      // 4/25  中午的时间段传上一个时间段的起止时间
      // debugger
      this.time = form.endTime.split('-')
      this.searchForm.start = form.startTime + " " + this.time[0] + ':00'
      this.searchForm.end = form.startTime + " " + this.time[2] + ':00'
      this.searchForm.center = form.startTime + " " + this.time[1] + ':00'

      this.searchForm.CheckingStartTimeOfEnterDormOnNoon = form.startTime + " " + this.time[3] + ':00'
      this.searchForm.CheckingEndTimeOfEnterDormOnNoon = form.startTime + " " + this.time[4] + ':00'

      form.startTime = this.searchForm.start
      form.endTime = this.searchForm.end
      form.center = this.searchForm.center

      if (form.deptName !== undefined && this.time.length > 3) {
        form.deptId = form.deptName
        form.CheckingStartTimeOfEnterDormOnNoon = this.searchForm.CheckingStartTimeOfEnterDormOnNoon
        form.CheckingEndTimeOfEnterDormOnNoon = this.searchForm.CheckingEndTimeOfEnterDormOnNoon
        this.searchForm = form
        this.page.currentPage = 1
        this.getList(this.page, form)
        done()
      } else if (form.deptName !== undefined) {
        form.deptId = form.deptName
        this.searchForm = form
        this.page.currentPage = 1
        this.getList(this.page, form)
        done()
      } else if (this.time.length > 3 && form.checkinState !== undefined) {
        // if(form.checkinState === '1'){
        //   this.tableData.map(item => {
        //       this.$set(item, 'noonParamCheckinState', 1)
        //   })
        //   console.log(this.tableData)
        // }
        // form.filterEndTime = this.searchForm.center
        // form.filterStartTime = this.searchForm.start
        form.paramCheckinTime = this.searchForm.center
        form.CheckingStartTimeOfEnterDormOnNoon = this.searchForm.CheckingStartTimeOfEnterDormOnNoon
        form.CheckingEndTimeOfEnterDormOnNoon = this.searchForm.CheckingEndTimeOfEnterDormOnNoon
        this.searchForm = form
        this.page.currentPage = 1
        this.getList(this.page, form)
        done()
      } else if (form.checkinState !== undefined) {
        // form.filterEndTime = this.searchForm.center
        // form.filterStartTime = this.searchForm.start
        form.paramCheckinTime = this.searchForm.center
        console.log(form)
        this.searchForm = form
        this.page.currentPage = 1
        this.getList(this.page, form)
        done()
      } else if (this.time.length > 3) {
        form.CheckingStartTimeOfEnterDormOnNoon = this.searchForm.CheckingStartTimeOfEnterDormOnNoon
        form.CheckingEndTimeOfEnterDormOnNoon = this.searchForm.CheckingEndTimeOfEnterDormOnNoon
        this.searchForm = form
        this.page.currentPage = 1
        this.getList(this.page, form)
        done()
      } else {
        this.searchForm = form
        this.page.currentPage = 1
        this.getList(this.page, form)
        done()
      }

    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize
    },
    currentChange(current) {
      this.page.currentPage = current
    },
    refreshChange() {
      this.getList(this.page)
    },
    searchReset() {
      this.searchForm = {};
      this.getList(this.page)
    },
    //  查看请假详情
    showLeave: function (row) {
      // debugger
      this.dialogLeaveVisible = true
      StudentLeave(row.personLeaveId).then(res => {
        if (res.data.code === 0) {
          this.detailform = res.data.data
          this.phone = this.detailform.linkPhone
          let strLen = this.phone.slice(-8, -4);
          this.newphone = this.phone.replace(strLen, "****");
        }
      });

    },
    dictItemVisible: function () {
      this.dialogLeaveVisible = false
    },
  }
}
</script>
<style scoped>
/*/deep/.avue-crud__menu{*/
/*  display: none;*/
/*}*/

/deep/ .el-form-item__label {
  text-align: left;
}

/deep/ .avue-form__row {
  padding-right: 16px !important;
}

/deep/ .avue-form__menu--center {
  text-align: left;
}
/deep/.el-form-item__label:before{
  float: right;
  margin-top: 3px;
}
</style>
